package com.sqlcheck.dto.request;

import com.sqlcheck.entity.CompatibilityRule;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

@Data
@Schema(description = "创建兼容性规则请求")
public class CreateCompatibilityRuleRequest {

    @NotBlank(message = "规则ID不能为空")
    @Schema(description = "规则ID", example = "RULE001", required = true)
    private String ruleId;

    @NotBlank(message = "规则名称不能为空")
    @Schema(description = "规则名称", example = "Oracle CHAR类型转换规则", required = true)
    private String ruleName;

    @NotBlank(message = "规则分类不能为空")
    @Schema(description = "规则分类", example = "DATA_TYPE", required = true)
    private String category;

    @NotNull(message = "源数据库类型不能为空")
    @Schema(description = "源数据库类型", example = "ORACLE", required = true)
    private CompatibilityRule.DbType sourceDbType;

    @NotNull(message = "目标数据库类型不能为空")
    @Schema(description = "目标数据库类型", example = "GOLDENDB", required = true)
    private CompatibilityRule.DbType targetDbType;

    @NotBlank(message = "规则模式不能为空")
    @Schema(description = "规则模式（正则表达式）", example = "CHAR\\(\\d+\\)", required = true)
    private String rulePattern;

    @NotNull(message = "严重程度不能为空")
    @Schema(description = "严重程度", example = "MEDIUM", required = true)
    private CompatibilityRule.Severity severity;

    @NotBlank(message = "问题描述不能为空")
    @Schema(description = "问题描述", example = "Oracle的CHAR类型在GoldenDB中需要转换为VARCHAR", required = true)
    private String description;

    @NotBlank(message = "修改建议不能为空")
    @Schema(description = "修改建议", example = "将CHAR类型替换为VARCHAR类型", required = true)
    private String suggestion;

    @Schema(description = "示例SQL", example = "CREATE TABLE test (name CHAR(50));")
    private String exampleSql;

    @Schema(description = "建议SQL", example = "CREATE TABLE test (name VARCHAR(50));")
    private String suggestedSql;

    @Schema(description = "是否启用", example = "true", defaultValue = "true")
    private Boolean isActive = true;
}